import mysql.connector
import _thread

mydb = mysql.connector.connect(
    host="39.103.180.180",  # 数据库主机地址
    user="root",  # 数据库用户名
    port=3307,
    database="study",  # 数据库名称 没有的话插入操作报错
    passwd="root",  # 数据库密码
    auth_plugin="mysql_native_password"
    # host="192.168.47.102",  # 数据库主机地址
    # port=3306,
    # user="ccmadmin",  # 数据库用户名
    # database="mh_xiyou",#数据库名称 没有的话插入操作报错
    # passwd="211314wccA@"  # 数据库密码
)

select_sql="SELECT id,msg FROM msg  where user = {} and is_send = 0"
update_sql="UPDATE msg SET is_send =1 WHERE id ={}"
insert_sql="INSERT INTO msg (msg,user_name) VALUES ({}, {})"
mycursor = mydb.cursor()

def accept():
    print("开始执行接收")
def send():
    print("开始执行发送")
   #_thread.start_new_thread( send_msg_to )


print("创建接收器线程")
_thread.start_new_thread( accept,())
print("创建发送器线程")
_thread.start_new_thread( send,())
while 1:
   pass
